package huachenxing.mimi520.skin
{
	import com.cambright.IDispose;
	
	import flash.text.AntiAliasType;
	import flash.text.GridFitType;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.utils.Proxy;
	import flash.utils.flash_proxy;
	
	public class Text extends TextField implements IDispose
	{
		use namespace flash_proxy;
		
		private var _textFormat:TextFormat;
		
		public function dispose():void
		{
			_textFormat = null;
		}
		
		public function Text(value:String = null)
		{
			if(value == null) value = "";
			_textFormat = new TextFormat("Microsoft YaHei UI", 15, 0xFFFFFF);
			_textFormat.letterSpacing = 2;
			defaultTextFormat = _textFormat;
			autoSize = TextFieldAutoSize.LEFT;
			mouseEnabled = false;
			antiAliasType = AntiAliasType.ADVANCED;
			gridFitType = GridFitType.SUBPIXEL;
			text = value;
		}
		
		public function get color():uint
		{
			return uint(_textFormat.color);
		}
		public function set color(value:uint):void
		{
			if(value == _textFormat.color) return;
			_textFormat.color = uint;
			defaultTextFormat = _textFormat;
			if(length > 0)
				setTextFormat(_textFormat, 0, length);
			textColor = value;
		}
		
		public function get size():uint
		{
			return uint(_textFormat.size);
		}
		public function set size(value:uint):void
		{
			if(value == _textFormat.size) return;
			_textFormat.size = value;
			defaultTextFormat = _textFormat;
			setTextFormat(_textFormat);
		}
		
		public function get font():String
		{
			return _textFormat.font;
		}
		public function set font(value:String):void
		{
			if(value == null || value == "") value = "Microsoft YaHei UI";
			if(value == _textFormat.font) return;
			_textFormat.font = value;
			defaultTextFormat = _textFormat;
			setTextFormat(_textFormat);
		}
	}
}